Full source code website bán hàng thương mại điện tử gần giống shopee
468.850 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Hang SX: <b> <a href="./?act=hangsx_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9
10 $MAXPAGE=20;
11
12 switch ($_GET['action'])
13 {
14 case 'del' :
15 $id = $_GET['id'];
16 $sql = "delete from hangsx where id='".$id."'";
17 @$result = mysql_query($sql,$con);
18 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
19 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
20
21 break;
22 }
23 ?>
24
25 <?
26 if (isset($_POST['ButDel'])) {
27 $cnt=0;
28 foreach ($_POST['chk'] as $id)
29 {
30 @$result = mysql_query("delete from hangsx where id='".$id."'",$con);
31 if ($result) $cnt++;
32 }
33 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
34 }
35 ?>
36 <?
37 $page = $_GET["page"];
38 $p=0;
39 if ($page!='') $p=$page;
40 $where="1=1";
41 if ($_REQUEST['cat']!='') $where="cat=".$_REQUEST['cat'];
42 ?>
43 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
44 <input type=hidden name="page" value="<? echo $page; ?>">
45 <?
46 function taotrang($sql,$link,$nitem,$itemcurrent)
47 { global $con;
48 $ret="";
49 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
50 $value = mysql_fetch_array($result);
51 $plus = (($value['cnt'] % $nitem)>0);
52 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
53 {
54 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
55 else $ret .= ($i+1)." ";
56 }
57 return $ret;
58 }
59 $pageindex=taotrang("select count(*) from hangsx where $where","./?act=hangsx&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
60 ?>
61 <table cellspacing="0" cellpadding="0" width="100%">
62 <? if ($_REQUEST['code']==1) echo '<tr><td colspan=2 align="center" class="err">Đã cập nhật thành công</td></tr>'; ?>
63 <tr>
64 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
65 </tr>
66 </table>
67 <table cellspacing="0" cellpadding="0" width="100%">
68 <tr>
69 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
70 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=hangsx_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
71 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
72 </td>
73 <td height="30" align="right" class="smallfont">
74 </td>
75 </tr>
76 </table>
77
78 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
79 <tr>
80 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
81 <td nowrap class="title"> </td>
82 <td nowrap class="title"> </td>
83 <td align="center" nowrap class="title"><b>Logo</b></td>
84 <td align="center" nowrap class="title"><b>Name</b></td>
85 <td align="center" nowrap class="title"><b>Danh muc</b></td>
86 <td align="center" nowrap class="title"><b>Order</b></td>
87 </tr>
88
89 <?
90 $sql="select * from hangsx where $where order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
91 $result=mysql_query($sql,$con);
92 $i=0;
93 while(($row=mysql_fetch_array($result)))
94 {
95 $i++;
96 $parent=explode(",",$row['cat']);
97 $sql_cat=mysql_query("SELECT * FROM cat where id='".$parent[$i]."'");
98 $row_cat=mysql_fetch_assoc($sql_cat);
99 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
100 ?>
101
102 <tr>
103 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
104 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
105 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
106 <a href="./?act=hangsx_m&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
107 Sửa</a></td>
108 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
109 <a href="./?act=hangsx&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
110 Xoá</a></td>
111 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><img src="../<? echo $row['logo']; ?>" width="100"> </td>
112 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
113 <td bgcolor="<? echo $color; ?>" class="smallfont">
114 <?php foreach($parent as $parent)
115 {
116 $sql_cat=mysql_query("SELECT * FROM cat where id='".$parent."'");
117 $row_cat=mysql_fetch_assoc($sql_cat);
118 ?>
119 <? echo $row_cat['name']; ?>,
120 <?}?>
121 </td>
122 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
123 </tr>
124 <?
125 }
126 ?>
127 </table>
128 <table cellspacing="0" cellpadding="0" width="100%">
129 <tr>
130 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
131 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=hangsx_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
132 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
133 </td>
134 <td height="30" align="right" class="smallfont">
135 </td>
136 </tr>
137 </table>
138 <input type="hidden" name="act" value="price">
139 </form>
140 <script language="JavaScript">
141 function chkallClick(o) {
142 var form = document.frmList;
143 for (var i = 0; i < form.elements.length; i++) {
144 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
145 form.elements[i].checked = document.frmList.chkall.checked;
146 }
147 }
148 }
149 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Hang SX: <b> <a href="./?act=hangsx_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9
10 $MAXPAGE=20;
11
12 switch ($_GET['action'])
13 {
14 case 'del' :
15 $id = $_GET['id'];
16 $sql = "delete from hangsx where id='".$id."'";
17 @$result = mysql_query($sql,$con);
18 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
19 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
20
21 break;
22 }
23 ?>
24
25 <?
26 if (isset($_POST['ButDel'])) {
27 $cnt=0;
28 foreach ($_POST['chk'] as $id)
29 {
30 @$result = mysql_query("delete from hangsx where id='".$id."'",$con);
31 if ($result) $cnt++;
32 }
33 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
34 }
35 ?>
36 <?
37 $page = $_GET["page"];
38 $p=0;
39 if ($page!='') $p=$page;
40 $where="1=1";
41 if ($_REQUEST['cat']!='') $where="cat=".$_REQUEST['cat'];
42 ?>
43 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
44 <input type=hidden name="page" value="<? echo $page; ?>">
45 <?
46 function taotrang($sql,$link,$nitem,$itemcurrent)
47 { global $con;
48 $ret="";
49 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
50 $value = mysql_fetch_array($result);
51 $plus = (($value['cnt'] % $nitem)>0);
52 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
53 {
54 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
55 else $ret .= ($i+1)." ";
56 }
57 return $ret;
58 }
59 $pageindex=taotrang("select count(*) from hangsx where $where","./?act=hangsx&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
60 ?>
61 <table cellspacing="0" cellpadding="0" width="100%">
62 <? if ($_REQUEST['code']==1) echo '<tr><td colspan=2 align="center" class="err">Đã cập nhật thành công</td></tr>'; ?>
63 <tr>
64 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
65 </tr>
66 </table>
67 <table cellspacing="0" cellpadding="0" width="100%">
68 <tr>
69 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
70 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=hangsx_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
71 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
72 </td>
73 <td height="30" align="right" class="smallfont">
74 </td>
75 </tr>
76 </table>
77
78 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
79 <tr>
80 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
81 <td nowrap class="title"> </td>
82 <td nowrap class="title"> </td>
83 <td align="center" nowrap class="title"><b>Logo</b></td>
84 <td align="center" nowrap class="title"><b>Name</b></td>
85 <td align="center" nowrap class="title"><b>Danh muc</b></td>
86 <td align="center" nowrap class="title"><b>Order</b></td>
87 </tr>
88
89 <?
90 $sql="select * from hangsx where $where order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
91 $result=mysql_query($sql,$con);
92 $i=0;
93 while(($row=mysql_fetch_array($result)))
94 {
95 $i++;
96 $parent=explode(",",$row['cat']);
97 $sql_cat=mysql_query("SELECT * FROM cat where id='".$parent[$i]."'");
98 $row_cat=mysql_fetch_assoc($sql_cat);
99 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
100 ?>
101
102 <tr>
103 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
104 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
105 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
106 <a href="./?act=hangsx_m&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
107 Sửa</a></td>
108 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
109 <a href="./?act=hangsx&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
110 Xoá</a></td>
111 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><img src="../<? echo $row['logo']; ?>" width="100"> </td>
112 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
113 <td bgcolor="<? echo $color; ?>" class="smallfont">
114 <?php foreach($parent as $parent)
115 {
116 $sql_cat=mysql_query("SELECT * FROM cat where id='".$parent."'");
117 $row_cat=mysql_fetch_assoc($sql_cat);
118 ?>
119 <? echo $row_cat['name']; ?>,
120 <?}?>
121 </td>
122 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
123 </tr>
124 <?
125 }
126 ?>
127 </table>
128 <table cellspacing="0" cellpadding="0" width="100%">
129 <tr>
130 <td class="smallfont" style="padding-top:10px;padding-bottom:10px">
131 <input type="button" value="+ Thêm mới" class="button" onclick="window.location='./?act=hangsx_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>'">
132 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
133 </td>
134 <td height="30" align="right" class="smallfont">
135 </td>
136 </tr>
137 </table>
138 <input type="hidden" name="act" value="price">
139 </form>
140 <script language="JavaScript">
141 function chkallClick(o) {
142 var form = document.frmList;
143 for (var i = 0; i < form.elements.length; i++) {
144 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
145 form.elements[i].checked = document.frmList.chkall.checked;
146 }
147 }
148 }
149 </script>